﻿<cfsilent>
	<cfscript>

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		depId = sessionAdvice.getUserProp("teacherDepartment");
		
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		termId = event.getArg("TermID", event.getArg("TID"));
	
		event.setArg("pageTitle", "学生选课管理 - 添加课程向导");
		
		currentTab = event.getArg("TabID", "labStudent");
		
		targetArgs = structNew();
		passArgs = structNew();
		structInsert(targetArgs, "TID", termId, true);
		structInsert(targetArgs, "TSK", taskId, true);
		structInsert(targetArgs, "TT", taskType, true);
		
		studentId = event.getArg("STU");
		
		/* 搜索学生档案 */
		cases = event.getArg("cases",'1');
		HSQL = "";
		keyword = trim(event.getArg("Keywords",studentId)) ;
		
		if( cases eq "" OR cases eq "1"){
			cases = "1";
			keyword = ucase(keyword);
			HSQL = "upper( ";
		}else if( cases eq "2"){
			keyword = lcase(keyword);
			HSQL = "Lower( ";
		}else{
			HSQL = "(";
		}
		
		structInsert(passArgs,"cases", cases );
		
		rs_student = queryNew("stu_id");
		
		if ( len(keyword) ) {
			
			
			sql = "SELECT 
						 " & HSQL & " t_student.stu_id ) stu_id,
						 " & HSQL & " t_student.stu_name_english ) stu_name_english, 
						 " & HSQL & " t_student.NATIONALITY ) NATIONALITY, 
						 " & HSQL & " t_student.stu_idcard ) stu_idcard, 
						 " & HSQL & " t_student.stu_name ) stu_name, 
						 " & HSQL & " t_student.stu_sex ) stu_sex, 
						 t_student_status.student_prop 
					FROM 
						 t_student 
						 INNER JOIN t_student_status ON t_student_status.stu_id = t_student.stu_id 
					WHERE 
						 (
							 " & HSQL & " t_student.stu_id ) LIKE :condition 
							 OR 
							 " & HSQL & " t_student.stu_name ) LIKE :condition 
							 OR 
							 " & HSQL & " t_student.stu_name_english ) LIKE :condition 
							 or 
							 " & HSQL & " T_STUDENT.stu_idcard ) LIKE :condition 
							 OR 
							 " & HSQL & " t_student.NATIONALITY ) like :condition 
						 )
						AND NOT EXISTS(
							SELECT 1 from t_student_course WHERE stu_Id = t_student.stu_Id and task_id = :taskId 
						)
					ORDER BY 
						 t_student.stu_name ";
			
			queryObj = new Query( datasource=application.dnsSlave, maxRows=30 );
			queryObj.addParam( name="condition", value="%"&keyword&"%", cfsqltype="cf_sql_varchar" );
			queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
			
			rs_student = queryObj.execute( sql=sql ).getResult();
	
						
		}
	
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('planTask', targetArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学任务</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 info"></i>确认要添加的学生
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="create">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labStudent">class="active"</cfif> id="labStudent" tabTarget="Student">查找学生</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				
				<div id="Student" class="tabContent">
				
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('applyWizardByCourse', targetArgs)#</cfoutput>">
						<input type="hidden" name="TabID" value="labStudent" />
						
						<div class="label">
							<b>学号、中文名、国家、<br/>护照名、护照号</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
                                   <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="1" <cfif event.getArg('cases', '1') eq 1>checked="checked"</cfif> />大写显示
                                    <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="2" <cfif event.getArg('cases', '1') eq 2>checked="checked"</cfif>/>小写显示
                                     <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="3" <cfif event.getArg('cases', '1') eq 3>checked="checked"</cfif>/>正常显示
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索" />
						</div>
					</form>
					
                    <cfif rs_student.recordCount>
                    	 <cfset row = 0 />
                           <table class="UIEditable">
                                <thead>
                                     <tr>
                                          <td width="18"></td>
                                          <td>学号</td>
                                          <td>中文名</td>
                                          <td>性别</td>
                                          <td>护照名</td>
                                          <td>护照号</td>
                                          <td>国籍</td>
                                          <td width="18"></td>
                                     </tr>
                                </thead>
                                <tbody>
                                     <cfloop query="rs_student">
                                     
                                          <cfset row++ />
                                          
                                          <cfset structInsert(passArgs, "STU", rs_student.stu_id, true) />
                                          <cfset structInsert(passArgs,"Keywords", keyword,true ) />
                                           <cfset structInsert(targetArgs, "STU", rs_student.stu_id, true) />
                                          
                                          <cfset propertyAdvice.parseProperty(rs_student.student_prop) />
                                          
                                          <tr class="editRows <cfif not propertyAdvice.getInSchool()>alertRow</cfif>">
                                               <td class="index"><cfoutput>#row#</cfoutput></td>
                                               <td><cfoutput>#replace(rs_student.stu_id,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                               <td><cfoutput>#replace(rs_student.stu_name,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                               <td><cfif rs_student.stu_sex eq "1">男<cfelse>女</cfif></td>
                                               <td><cfoutput>#replace(rs_student.stu_name_english,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                               <td><cfoutput>#replace(rs_student.stu_idcard,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                               <td><cfoutput>#replace(rs_student.nationality,keyword,"<font color=red>" & keyword & "</font>")#</cfoutput></td>
                                               <td><a href="<cfoutput>#buildURL('applyWizardByCourseDetail', targetArgs)#</cfoutput>" class="stat select"></a></td>
                                              
                                          </tr>
                                     </cfloop>
                                </tbody>
                           </table>

					
					</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>